package com.softer.wxzj.controller;


import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.service.FlowInstanceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * FlowInstanceController class
 *
 * @author zcz
 * @date 2019/4/10
 */
@RestController
@RequestMapping("/flowInstance")
@Slf4j
public class FlowInstanceController {
    @Autowired
    FlowInstanceService flowInstanceService;

    /**
     * 新增提交审核
     *
     * @param id       业务ID
     * @param flowType
     * @return
     */
    @RequestMapping("/submit_audit")
    @LogRecord(description = "新增提交审核", operationUnit = LogOperationUnit.FLOW_INSTANCE, operationType = LogOperationType.INSERT)
    public CommonResult submitAudit(@RequestParam("id") String id, @RequestParam("flowType") String flowType) {
        return flowInstanceService.submit_audit(id, flowType);
    }

    /**
     * 根据业务id检查是否可更新
     *
     * @param id
     * @return
     */
    @RequestMapping("/checkUpdateCondition")
    public CommonResult checkUpdateCondition(@RequestParam("id") String id) {
        return flowInstanceService.checkUpdateCondition(id);
    }

    /**
     * 根据业务id检查在审核的业务
     *
     * @param id
     * @return
     */
    @RequestMapping("/getListByBusinessId")
    public CommonResult getListByBusinessId(@RequestParam("id") String id) {
        return flowInstanceService.getListByBusinessId(id);
    }
}
